use std::collections::HashMap;

fn main() {
    // 新建一个键值对映射
    let mut fruits = HashMap::new();
    fruits.insert("apple", 3);
    fruits.insert("mango", 6);
    fruits.insert("orange", 2);
    fruits.insert("avocado", 7);
    // &fruits水果映射结构
    // (k, v)元祖
    // 还可以keys()和values()来分别遍历
    for (k, v) in &fruits {
        println!("I got {} \t {}", k, v);
    }

    fruits.remove("orange");

    let old_avocado = fruits["avocado"];
    fruits.insert("avocado", old_avocado + 5);
    println!("\nI now have {} avocado", fruits["avocado"]);
}
